/*
编写 : Hexh
时间 : 2012-7-9 10:48:31
*/
using System;
using System.Collections;
using System.Text;
using HMIS.FrameWork.DomainBase;
using HMIS.Infrastructure.Core.Entities;
using System.Linq;
using Iesi.Collections.Generic;
using System.Collections.Generic;

namespace FsCarInfo.Core.Entity
{
	/// <summary>
	///	the entity of FsGatelog
	/// </summary>
	public  class FsGatelog : InputItem
	{

		#region Public Properties
			
		/// <summary>
		/// 出入类型
		/// </summary>
		public virtual InfraIdcardType Type { get; set; }

		/// <summary>
		/// ID卡编号
		/// </summary>
		public virtual string CardUid { get; set; }

		/// <summary>
		/// ID卡出入控制信息
		/// 与道闸信息判断生成
		/// </summary>
		public virtual string IoControlFlag { get; set; }

		/// <summary>
		/// ID卡信息
		/// </summary>
		public virtual InfraIdcard InfraIdcard { get; set; }

		/// <summary>
		/// 车牌
		/// </summary>
		public virtual string CarNo { get; set; }

		/// <summary>
		/// 当前道闸信息
		/// </summary>
		public virtual FsGateinfo CurrentGate { get; set; }

		/// <summary>
		/// 进入时间
		/// </summary>
		public virtual DateTime? EntTime { get; set; }

		/// <summary>
		/// 离开时间
		/// </summary>
		public virtual DateTime? LevTime { get; set; }

		/// <summary>
		/// 状态 0未结束 1结束
		/// </summary>
		public virtual string State { get; set; }

		/// <summary>
		/// 该通行信息包括的闸机记录
		/// </summary>
		public virtual Iesi.Collections.Generic.ISet<FsGatelogList> GateLogList { get; set; }

		/// <summary>
		/// 未授权的通行记录
		/// </summary>
		public virtual List<FsGatelogList> UnApprLogList
		{
			get
			{
				if (this.GateLogList == null || this.GateLogList.Count == 0)
					return null;
				return this.GateLogList.Where(c => c.ApprState == "0").ToList<FsGatelogList>();
			}
		}

		/// <summary>
		/// 最近一条闸机记录
		/// </summary>
		public virtual FsGatelogList LatestGateLog
		{
			get
			{
				if (this.GateLogList == null || this.GateLogList.Count == 0)
					return null;
				return this.GateLogList.OrderByDescending(c => c.CreateTime).FirstOrDefault();
			}
		}

		#endregion 
	
	}
}
